package com.softer.wxzj.controller;/**
 * @author Gong Zhiyang
 * @date 2019/6/26
 */

import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.aop.annotation.LogRecord;
import com.softer.wxzj.common.aop.enums.LogOperationType;
import com.softer.wxzj.common.aop.enums.LogOperationUnit;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.entity.BaseRegionInfo;
import com.softer.wxzj.entity.DepositAudit;
import com.softer.wxzj.entity.DepositAuditRequest;
import com.softer.wxzj.service.DepositAuditService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 交存审核
 *
 * @author Gong Zhiyang
 * @date 2019/6/26
 */
@RestController
@RequestMapping("/depositAudit")
@Slf4j
public class DepositAuditController {
    @Autowired
    private DepositAuditService depositAuditService;

    /**
     * 交存审核
     *
     * @param depositAuditRequest list    审核ID
     *                            opinion 审批意见
     *                            mark    审批通过 audit_pass
     *                            审批否决 audit_veto
     *                            审批退回 audit_back
     * @return 操作结果
     */
    @RequestMapping("/audit")
    @LogRecord(description = "交存审核", operationUnit = LogOperationUnit.DEPOSIT, operationType = LogOperationType.UPDATE)
    public CommonResult audit(@RequestBody DepositAuditRequest depositAuditRequest) {
        return depositAuditService.audit(depositAuditRequest.getList(), depositAuditRequest.getOpinion(), depositAuditRequest.getMark());
    }

    /**
     * 交存全部审核
     *
     * @param id      小区ID
     * @param opinion 审批意见
     * @param mark    审批通过 audit_pass
     *                审批否决 audit_veto
     *                审批退回 audit_back
     * @return 操作结果
     */
    @RequestMapping("/auditAll")
    @LogRecord(description = "交存全部审核", operationUnit = LogOperationUnit.DEPOSIT, operationType = LogOperationType.UPDATE)
    public CommonResult auditAll(String id, String opinion, String mark) {
        return depositAuditService.auditAll(id, opinion, mark);
    }

    /**
     * 精确查询/模糊查询 待审核列表
     *
     * @param page           分页信息
     * @param baseRegionInfo 精确查询实体
     * @param arcType        图档类型（逗号分隔）
     * @return 待审核列表
     */
    @RequestMapping("/getAuditList")
    @LogRecord(description = "查询交存审核列表", operationUnit = LogOperationUnit.DEPOSIT, operationType = LogOperationType.SELECT)
    public PageInfo<BaseRegionInfo> getAuditList(Page page, BaseRegionInfo baseRegionInfo, String arcType) {
        return depositAuditService.getAuditList(page, baseRegionInfo, arcType);
    }

    /**
     * 查询单个小区交存审核列表
     *
     * @param id 小区ID
     * @return 审核列表
     */
    @RequestMapping("/getAuditListByRegionId")
    @LogRecord(description = "查询单个小区交存审核列表", operationUnit = LogOperationUnit.DEPOSIT, operationType = LogOperationType.SELECT)
    public List<DepositAudit> getAuditListByRegionId(String id) {
        return depositAuditService.getAuditListByRegionId(id);
    }

    /**
     * 交存审核查询列表
     *
     * @param page         分页实体
     *                     pageNum 页码
     *                     pageSize 每页条数
     * @param depositAudit 查询实体
     *                     regionName 小区名称
     *                     regionNo 小区编码
     *                     houseSite房屋地址
     *                     flowState 审核状态
     *                     creater 申请人
     * @param fuzzy        模糊查询字段
     * @return 审核查询列表
     */
    @RequestMapping("/getAuditSearchList")
    @LogRecord(description = "查询交存审核查询列表", operationUnit = LogOperationUnit.DEPOSIT, operationType = LogOperationType.SELECT)
    public PageInfo<DepositAudit> getAuditSearchList(Page page, DepositAudit depositAudit, String fuzzy) {
        return depositAuditService.getAuditSearchList(page, depositAudit, fuzzy);
    }
}
